package com.zte.springboot_smbms.service.impl;

import com.zte.springboot_smbms.mapper.SmbmsUserMapper;
import com.zte.springboot_smbms.pojo.SmbmsUser;
import com.zte.springboot_smbms.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UsersServiceImpl implements UsersService {
    @Autowired
    private SmbmsUserMapper smbmsUserMapper;

    /*public void setSmbmsUserMapper(SmbmsUserMapper smbmsUserMapper) {
        this.smbmsUserMapper = smbmsUserMapper;
    }*/

    @Override
    @Transactional(readOnly = true)
    public List<SmbmsUser> findAllUsers() {
        return smbmsUserMapper.findAllUsers();
    }

    @Override
    @Transactional(readOnly = true)
    public List<SmbmsUser> findAllUsersById(Long id) {
        return smbmsUserMapper.findAllUsersById(id);
    }

    @Override
    @Transactional(readOnly = false)
    public boolean addUser(SmbmsUser user) {
        return smbmsUserMapper.addUser(user);
    }

    @Override
    @Transactional(readOnly = false)
    public boolean delUserById(Long id) {
        return smbmsUserMapper.delUserById(id);
    }

    @Override
    @Transactional(readOnly = false)
    public boolean updateUserById(Long id ,SmbmsUser user) {
        return smbmsUserMapper.updateUserById(id,user);
    }

    @Override
    @Transactional(readOnly = true)
    public SmbmsUser login(String uCode, String uPwd) {
        return smbmsUserMapper.login(uCode,uPwd);
    }

    @Override
    @Transactional(readOnly = true)
    public List<SmbmsUser> findUserByParam(String queryname, Integer queryUserRole) {
        return smbmsUserMapper.findUserByParam(queryname,queryUserRole);
    }


    @Override
    @Transactional(readOnly = true)
    public SmbmsUser findUserByCode(String usercode) {
        return smbmsUserMapper.findUserByCode(usercode);
    }
}
